#include "view_prompt.h"
#include "view_common.h"
#include "display_ctrl.h"
#include "platform_assert.h"
#include "lfs_file_manager_auto.h"
#include "rtc.h"
#include "datetime.h"
#include "blecom.h"
#include "battery_ctrl.h"
#include "sport_his.h"
#include "display_ctrl.h"
#include "display_interface_240x240.h"
#include "datetime.h"
#include "heart_rate_interface.h"
#include "font/num_font.h"
#include "font_mngr.h"
#include "app_trace.h"
#include "view_prompt_message.h"
#include "view.h"
#include "motor.h"
#include "app_timer.h"
#include "view_prompt.inc"
#if defined(USE_CT1711)
#include "body_temperature.h"
#endif
#define LOG(fmt, ...) // app_trace_log(fmt "\r\n", ##__VA_ARGS__)
#define ANIMATION_TICKS_MAX (APP_TIMER_CLOCK_FREQ)
// ANCS中转的变量
void view_prompt_not_connect_display(void)
{
    if (disp_ctrl.loop_cnt == 0)
    {
        disp_ctrl.auto_refresh_time = 1000;
        disp_ctrl.auto_close_delay = disp_ctrl.auto_refresh_time + 1000;
        if (disp_ctrl.auto_refresh_count >= 3)
        {
            display_show_type_recover();
            return;
        }
    }
    _disp_show_flash_img(DISP_LFS_FILE_INDEX_0, 71, 43, FILE_IMG_T102_nocon_71_43);
    // _disp_show_flash_img(DISP_LFS_FILE_INDEX_1, 52, 147, FILE_IMG_T103_nocon_52_147);
    disp_show_localize(DISP_LFS_FILE_INDEX_1, localize_string_key_AlertNotConnected, 50);
}
void view_prompt_bind_success_display(void)
{
    if (disp_ctrl.loop_cnt == 0)
    {
        disp_ctrl.auto_refresh_time = 1000;
        disp_ctrl.auto_close_delay = disp_ctrl.auto_refresh_time + 1000;
        if (disp_ctrl.auto_refresh_count >= 3)
        {
            display_show_type_recover();
            return;
        }
    }
    _disp_show_flash_img(DISP_LFS_FILE_INDEX_0, 76, 43, FILE_IMG_T104_con_76_43);
    // _disp_show_flash_img(DISP_LFS_FILE_INDEX_1, 71, 147, FILE_IMG_T105_con_71_147);
    disp_show_localize(DISP_LFS_FILE_INDEX_1, localize_string_key_AlertConnected, 50);
}
void view_prompt_camera_ready_display(void)
{
    if (disp_ctrl.loop_cnt == 0)
    {
        disp_ctrl.auto_refresh_time = 100;
        disp_ctrl.auto_close_delay = 1000;
        if (disp_ctrl.auto_refresh_count > 8)
        {
            display_show(view_prompt_camera_fail, DISP_MODE_NORMAL);
            return;
        }
    }
    int x = 32;
    int y = 73;
    _disp_show_flash_img(DISP_LFS_FILE_INDEX_0, x, y, FILE_IMG_9406_prompt_02);
    int index = FILE_IMG_9406_prompt_03 + disp_ctrl.auto_refresh_count % 9;
    x = 94;
    y = 110;
    _disp_show_flash_img(DISP_LFS_FILE_INDEX_1, x, y, index);
}
void view_prompt_camera_fail_display(void)
{
    if (disp_ctrl.loop_cnt == 0)
    {
        disp_ctrl.auto_refresh_time = 1000;
        disp_ctrl.auto_close_delay = disp_ctrl.auto_refresh_time + 1000;
        if (disp_ctrl.auto_refresh_count >= 3)
        {
            display_show_type_recover();
            return;
        }
    }
    _disp_show_flash_img(DISP_LFS_FILE_INDEX_0, 94, 21, FILE_IMG_9408_prompt_94_21);
    disp_show_localize(DISP_LFS_FILE_INDEX_1, localize_string_key_OpenAppAlert, 50);
}
bool view_prompt_distance_complete_event(int32_t view, event_param_t param)
{
    switch (param.event)
    {
    case event_view_entry:
        // app_timer_cnt_get(&disp_ctrl.com_data.u_temp[20]);
        // disp_ctrl.com_data.u_temp[21] = 0;
        return true;
    }
    return false;
}

bool view_prompt_calories_complete_event(int32_t view, event_param_t param)
{
    switch (param.event)
    {
    case event_view_entry:
        // app_timer_cnt_get(&disp_ctrl.com_data.u_temp[20]);
        // disp_ctrl.com_data.u_temp[21] = 0;
        return true;
    }
    return false;
}
bool view_prompt_steps_complete_event(int32_t view, event_param_t param)
{
    switch (param.event)
    {
    case event_view_entry:
        // app_timer_cnt_get(&disp_ctrl.com_data.u_temp[20]);
        // disp_ctrl.com_data.u_temp[21] = 0;
        return true;
    }
    return false;
}
#if defined(USE_CT1711)
bool view_prompt_hyperthemia_event(int32_t view, event_param_t param)
{
    switch (param.event)
    {
    case BUTTON_EVENT_SHORT_PRESS:
        display_show_type_recover();
        return true;
    }
    return false;
}
#endif
bool view_prompt_find_wrist_event(int32_t view, event_param_t param)
{
    switch (param.event)
    {
    case event_view_exit:
    {
        motor_stop();
        return true;
    }
    }
    return false;
}
void view_prompt_distance_complete_display(void)
{
    if (disp_ctrl.loop_cnt == 0)
    {
        disp_ctrl.com_data.i_temp[0] = sport_get_distance();
        if (system_config_get_km_mi() != 0)
        {
            disp_ctrl.com_data.i_temp[0] *= 0.6213712;
        }
        disp_ctrl.auto_refresh_time = 1000;
        disp_ctrl.auto_close_delay = disp_ctrl.auto_refresh_time + 1000;
        if (disp_ctrl.auto_refresh_count > 5)
        {
            display_show_type_recover();
            return;
        }
    }
    user_cycle_percent_param_t const param_distance = {
        .base = target_complete_base,
        .transparent_color = RGB565_COLOR_BLACK,
        .full_color = 0xbfa,
        .empty_color = 0x8c5,
        .x = 0,
        .y = 0,
        .target_num = disp_ctrl.com_data.i_temp[0],
        .presently_num = disp_ctrl.com_data.i_temp[0], // * disp_ctrl.com_data.u_temp[21] / ANIMATION_TICKS_MAX,
        .temp_0 = &disp_ctrl.com_data.i_temp[10],
        .temp_1 = &disp_ctrl.com_data.i_temp[11],
        .temp_2 = &disp_ctrl.com_data.f_temp[12],
        .temp_3 = &disp_ctrl.com_data.i_temp[13],
        .temp_4 = &disp_ctrl.com_data.i_temp[14],
        .line_width = 4,
    };
    disp_draw_user_image_cycle_percent(&param_distance);
    int x = 101;
    int y = 26;
    disp_draw_user_image(x, y, bmp_target_complete_icon);
    // x = 78;
    // y = 137;
    // disp_draw_user_image(x, y, bmp_distance_complete_text_0);
    // x = 51;
    // y = 174;
    // disp_draw_user_image(x, y, bmp_distance_complete_text_1);
    disp_show_localize(DISP_LFS_FILE_INDEX_1, localize_string_key_alertDistancesComplete1, 50);
    disp_show_localize(DISP_LFS_FILE_INDEX_2, localize_string_key_alertDistancesComplete2, 51);
    disp_draw_user_image_num_mid_ignore(120, 91, RGB565_COLOR_BLACK, disp_ctrl.com_data.i_temp[0], 24, num_15x37_TAB);
}
void view_prompt_calories_complete_display(void)
{
    if (disp_ctrl.loop_cnt == 0)
    {
        disp_ctrl.com_data.i_temp[0] = sport_get_calorie();
        disp_ctrl.auto_refresh_time = 1000;
        disp_ctrl.auto_close_delay = disp_ctrl.auto_refresh_time + 1000;
        if (disp_ctrl.auto_refresh_count > 5)
        {
            display_show_type_recover();
            return;
        }
    }
    // #warning debug
    // disp_ctrl.com_data.i_temp[0] = 23456;
    user_cycle_percent_param_t const param_calories = {
        .base = target_complete_base,
        .transparent_color = RGB565_COLOR_BLACK,
        .full_color = 0xed08,
        .empty_color = 0x28c1,
        .x = 0,
        .y = 0,
        .target_num = disp_ctrl.com_data.i_temp[0],
        .presently_num = disp_ctrl.com_data.i_temp[0], // * disp_ctrl.com_data.u_temp[21] / ANIMATION_TICKS_MAX,
        .temp_0 = &disp_ctrl.com_data.i_temp[10],
        .temp_1 = &disp_ctrl.com_data.i_temp[11],
        .temp_2 = &disp_ctrl.com_data.f_temp[12],
        .temp_3 = &disp_ctrl.com_data.i_temp[13],
        .temp_4 = &disp_ctrl.com_data.i_temp[14],
        .line_width = 4,
    };
    disp_draw_user_image_cycle_percent(&param_calories);
    int x = 101;
    int y = 26;
    disp_draw_user_image(x, y, bmp_target_complete_icon);
    // x = 79;
    // y = 137;
    // disp_draw_user_image(x, y, bmp_calories_complete_text_0);
    // x = 51;
    // y = 174;
    // disp_draw_user_image(x, y, bmp_calories_complete_text_1);
    disp_show_localize(DISP_LFS_FILE_INDEX_1, localize_string_key_alertCaloriesComplete1, 50);
    disp_show_localize(DISP_LFS_FILE_INDEX_2, localize_string_key_alertCaloriesComplete2, 51);
    disp_draw_user_image_num_mid_ignore(120, 91, RGB565_COLOR_BLACK, disp_ctrl.com_data.i_temp[0], 24, num_15x37_TAB);
}

void view_prompt_steps_complete_display(void)
{
    if (disp_ctrl.loop_cnt == 0)
    {
        disp_ctrl.com_data.i_temp[0] = sport_get_present_step();
        disp_ctrl.auto_refresh_time = 1000;
        disp_ctrl.auto_close_delay = disp_ctrl.auto_refresh_time + 1000;
        if (disp_ctrl.auto_refresh_count > 5)
        {
            display_show_type_recover();
            return;
        }
    }
    //#warning debug
    //    disp_ctrl.com_data.i_temp[0] = 23456;
    user_cycle_percent_param_t const param_steps = {
        .base = target_complete_base,
        .transparent_color = RGB565_COLOR_BLACK,
        .full_color = 0x1e57,
        .empty_color = 0x28c1,
        .x = 0,
        .y = 0,
        .target_num = disp_ctrl.com_data.i_temp[0],
        .presently_num = disp_ctrl.com_data.i_temp[0], // * disp_ctrl.com_data.u_temp[21] / ANIMATION_TICKS_MAX,
        .temp_0 = &disp_ctrl.com_data.i_temp[10],
        .temp_1 = &disp_ctrl.com_data.i_temp[11],
        .temp_2 = &disp_ctrl.com_data.f_temp[12],
        .temp_3 = &disp_ctrl.com_data.i_temp[13],
        .temp_4 = &disp_ctrl.com_data.i_temp[14],
        .line_width = 4,
    };
    disp_draw_user_image_cycle_percent(&param_steps);
    int x = 101;
    int y = 26;
    disp_draw_user_image(x, y, bmp_target_complete_icon);
    // x = 100;
    // y = 136;
    // disp_draw_user_image(x, y, bmp_step_complete_text_0);
    // x = 51;
    // y = 174;
    // disp_draw_user_image(x, y, bmp_step_complete_text_1);
    disp_show_localize(DISP_LFS_FILE_INDEX_1, localize_string_key_alertStepsComplete1, 50);
    disp_show_localize(DISP_LFS_FILE_INDEX_2, localize_string_key_alertStepsComplete2, 51);
    disp_draw_user_image_num_mid_ignore(120, 91, RGB565_COLOR_BLACK, disp_ctrl.com_data.i_temp[0], 24, num_15x37_TAB);
}
void view_prompt_lost_display(void)
{
}
void view_prompt_drink_display(void)
{
    if (disp_ctrl.loop_cnt == 0)
    {
        disp_ctrl.auto_refresh_time = 1000;
        disp_ctrl.auto_close_delay = disp_ctrl.auto_refresh_time + 1000;
        if (disp_ctrl.auto_refresh_count >= 5)
        {
            display_show_type_recover();
        }
    }
    _disp_show_flash_img(DISP_LFS_FILE_INDEX_0, 70, 45, FILE_IMG_T110_drinkwater_70_45);
    // _disp_show_flash_img(DISP_LFS_FILE_INDEX_1, 65, 147, FILE_IMG_T111_drinkwater_text_65_147);
    disp_show_localize(DISP_LFS_FILE_INDEX_1, localize_string_key_AlertDrink, 50);
}
#if defined(USE_CT1711)
void view_prompt_hyperthemia_display(void)
{
    if (disp_ctrl.loop_cnt == 0)
    {
        if (disp_ctrl.auto_refresh_count == 0)
        {
            motor_start(200);
        }
        disp_ctrl.auto_refresh_time = 1000;
        disp_ctrl.auto_close_delay = disp_ctrl.auto_refresh_time + 1000;
        if (disp_ctrl.auto_refresh_count >= 5)
        {
            display_show_type_recover();
        }
        datetime_t UIdatetime = DateSync();
        disp_ctrl.com_data.i_temp[3] = UIdatetime.time.hour;
        if (if_time_hour_system_12())
        {
            disp_ctrl.com_data.i_temp[3] %= 12;
            if (disp_ctrl.com_data.i_temp[3] == 0)
            {
                disp_ctrl.com_data.i_temp[3] = 12;
            }
        }
        disp_ctrl.com_data.i_temp[4] = UIdatetime.time.minute;
        disp_ctrl.com_data.i_temp[8] = battery_ctrl_if_charging();
        disp_ctrl.com_data.i_temp[9] = battery_ctrl_get_percent();
        disp_ctrl.com_data.i_temp[5] = ble_if_connected();
    }
    // if (disp_ctrl.com_data.i_temp[5])
    // {
    //     disp_draw_user_image(42, 3, img_ble_connect);
    // }
    // else
    // {
    //     disp_draw_user_image(42, 0, img_ble_disconnect);
    // }
    // show_common_time(disp_ctrl.com_data.i_temp[3], disp_ctrl.com_data.i_temp[4]);
    // show_time_0_battery(disp_ctrl.com_data.i_temp[9], disp_ctrl.com_data.i_temp[8]);
    _disp_show_flash_img(DISP_LFS_FILE_INDEX_0, 93, 34, FILE_IMG_icon_93_342);
    disp_show_localize(DISP_LFS_FILE_INDEX_1, localize_string_key_Hyperthemia, 50);
}
void view_prompt_body_temperature_fail_display(void)
{
    if (disp_ctrl.loop_cnt == 0)
    {
        if (disp_ctrl.auto_refresh_count == 0)
        {
            motor_start(200);
        }
        disp_ctrl.auto_refresh_time = 1000;
        disp_ctrl.auto_close_delay = disp_ctrl.auto_refresh_time + 1000;
        if (disp_ctrl.auto_refresh_count >= 5)
        {
            display_show_type_recover();
        }
        datetime_t UIdatetime = DateSync();
        disp_ctrl.com_data.i_temp[3] = UIdatetime.time.hour;
        if (if_time_hour_system_12())
        {
            disp_ctrl.com_data.i_temp[3] %= 12;
            if (disp_ctrl.com_data.i_temp[3] == 0)
            {
                disp_ctrl.com_data.i_temp[3] = 12;
            }
        }
        disp_ctrl.com_data.i_temp[4] = UIdatetime.time.minute;
        disp_ctrl.com_data.i_temp[8] = battery_ctrl_if_charging();
        disp_ctrl.com_data.i_temp[9] = battery_ctrl_get_percent();
        disp_ctrl.com_data.i_temp[5] = ble_if_connected();
    }
    // if (disp_ctrl.com_data.i_temp[5])
    // {
    //     disp_draw_user_image(42, 3, img_ble_connect);
    // }
    // else
    // {
    //     disp_draw_user_image(42, 0, img_ble_disconnect);
    // }
    // show_common_time(disp_ctrl.com_data.i_temp[3], disp_ctrl.com_data.i_temp[4]);
    // show_time_0_battery(disp_ctrl.com_data.i_temp[9], disp_ctrl.com_data.i_temp[8]);

    _disp_show_flash_img(DISP_LFS_FILE_INDEX_0, 69, 32, FILE_IMG_icon_69_322);
    disp_show_localize(DISP_LFS_FILE_INDEX_1, localize_string_key_MeasuringBodyTemperatureFailTips, 50);
}
#endif
void view_prompt_sedentariness_display(void)
{
    if (disp_ctrl.loop_cnt == 0)
    {
        disp_ctrl.auto_refresh_time = 1000;
        disp_ctrl.auto_close_delay = disp_ctrl.auto_refresh_time + 1000;
        if (disp_ctrl.auto_refresh_count >= 5)
        {
            display_show_type_recover();
        }
    }
    _disp_show_flash_img(DISP_LFS_FILE_INDEX_0, 90, 39, FILE_IMG_T106_sed_90_39);
    // _disp_show_flash_img(DISP_LFS_FILE_INDEX_1, 26, 147, FILE_IMG_T107_sed_text_26_147);
    disp_show_localize(DISP_LFS_FILE_INDEX_1, localize_string_key_AlertSedentary, 50);
}
void view_prompt_low_power_display(void)
{
    if (disp_ctrl.loop_cnt == 0)
    {
        disp_ctrl.auto_refresh_time = 1000;
        disp_ctrl.auto_close_delay = disp_ctrl.auto_refresh_time + 1000;
        if (disp_ctrl.auto_refresh_count >= 5)
        {
            display_show_type_recover();
        }
    }
    _disp_show_flash_img(DISP_LFS_FILE_INDEX_0, 60, 62, FILE_IMG_T108_lowbattery_60_62);
    // _disp_show_flash_img(DISP_LFS_FILE_INDEX_1, 64, 147, FILE_IMG_T109_lowbattery_text_64_147);
    disp_show_localize(DISP_LFS_FILE_INDEX_1, localize_string_key_AlertLowBattery, 50);
}
void view_prompt_not_wear_display(void)
{
    if (disp_ctrl.loop_cnt == 0)
    {
        disp_ctrl.auto_refresh_time = 1000;
        disp_ctrl.auto_close_delay = disp_ctrl.auto_refresh_time + 1000;
        if (disp_ctrl.auto_refresh_count >= 5)
        {
            display_show_type_recover();
        }
    }
    _disp_show_flash_img(DISP_LFS_FILE_INDEX_0, 66, 64, FILE_IMG_T112_not_wear_66_64);
    // _disp_show_flash_img(DISP_LFS_FILE_INDEX_1, 24, 147, FILE_IMG_T113_not_wear_text_24_147);
    disp_show_localize(DISP_LFS_FILE_INDEX_1, localize_string_key_AlertNotWear, 50);
}
void view_prompt_find_wrist_display(void)
{
    if (disp_ctrl.loop_cnt == 0)
    {
        disp_ctrl.auto_refresh_time = 250;
        disp_ctrl.auto_close_delay = disp_ctrl.auto_refresh_time + 1000;
        if (disp_ctrl.auto_refresh_count >= 40)
        {
            display_show_type_recover();
            return;
        }
    }
    _disp_show_flash_img(DISP_LFS_FILE_INDEX_0, 52, 52, FILE_IMG_SJDJ_52_52);
    int x = 0;
    int y = 0;
    switch (disp_ctrl.auto_refresh_count % 4)
    {
    case 0:
        x = 46;
        y = 54;
        break;
    case 1:
        x = 54;
        y = 59;
        break;

    case 2:
        x = 60;
        y = 54;
        break;

    case 3:
        x = 53;
        y = 47;
        break;
    }
    disp_draw_user_image(52 + x, 52 + y, icon_find_wrist);
}
void view_prompt_charing_display(void)
{
    if (disp_ctrl.loop_cnt == 0)
    {
        disp_ctrl.auto_refresh_time = 500;
    }
    int x = 39;
    int y = 83;
    img_gif_com_t const img_cfg_2 = {
        .gif_count = 3,
        .img[0].x = x,
        .img[0].y = y,
        .img[0].sn = FILE_IMG_T211_Charging_1_43_71,
        .img[1].x = x,
        .img[1].y = y,
        .img[1].sn = FILE_IMG_T212_Charging_2_43_71,
        .img[2].x = x,
        .img[2].y = y,
        .img[2].sn = FILE_IMG_T213_Charging_3_43_71,
    };
    _disp_show_flash_img_gif_all(&img_cfg_2, DISP_LFS_FILE_INDEX_0);
}
void view_prompt_alarm_display(void)
{
    if (disp_ctrl.loop_cnt == 0)
    {
        disp_ctrl.auto_refresh_time = 1000;
        disp_ctrl.auto_close_delay = disp_ctrl.auto_refresh_time + 1000;
        if (disp_ctrl.auto_refresh_count >= 30)
        {
            display_show_type_recover();
        }

        datetime_t UIdatetime = DateSync();
        disp_ctrl.com_data.i_temp[0] = UIdatetime.time.hour;
        disp_ctrl.com_data.i_temp[1] = UIdatetime.time.minute;
        if (if_time_hour_system_12())
        {
            disp_ctrl.com_data.i_temp[0] %= 12;
            if (disp_ctrl.com_data.i_temp[0] == 0)
            {
                disp_ctrl.com_data.i_temp[0] = 12;
            }
        }
    }
    int x = 80;
    int y = 45;
    _disp_show_flash_img(DISP_LFS_FILE_INDEX_0, x, y, FILE_IMG_T114_alark_80_45);

    x = 86;
    y = 153;
    x = disp_draw_user_image_num_with_digits(x, y, disp_ctrl.com_data.i_temp[0], 2, 14, num_12x29_TAB);
    // x += 3;
    // disp_draw_user_image(x, y, num_N312_second_6x32);
    x = 118;
    y = 165;
    // disp_draw_rect_color(x, y, x + 3 - 1, y + 3 - 1, RGB565_COLOR_WHITE);
    disp_draw_user_image(x, y, num_12x29_dot);
    y = 178;
    // disp_draw_rect_color(x, y, x + 3 - 1, y + 3 - 1, RGB565_COLOR_WHITE);
    disp_draw_user_image(x, y, num_12x29_dot);
    x += 9;
    y = 153;
    x = disp_draw_user_image_num_with_digits(x, y, disp_ctrl.com_data.i_temp[1], 2, 14, num_12x29_TAB);
}
bool view_prompt_display(int view)
{
    switch (view)
    {
    case view_prompt_message:
        view_prompt_message_display();
        return true;
    case view_prompt_not_connect:
        view_prompt_not_connect_display();
        return true;
    case view_prompt_distance_complete:
        view_prompt_distance_complete_display();
        return true;
    case view_prompt_calories_complete:
        view_prompt_calories_complete_display();
        return true;
    case view_prompt_steps_complete:
        view_prompt_steps_complete_display();
        return true;
    case view_prompt_lost:
        view_prompt_lost_display();
        return true;
    case view_prompt_drink:
        view_prompt_drink_display();
        return true;
    case view_prompt_alarm:
        view_prompt_alarm_display();
        return true;
    case view_prompt_sedentariness:
        view_prompt_sedentariness_display();
        return true;
    case view_prompt_low_power:
        view_prompt_low_power_display();
        return true;
    case view_prompt_charing:
        view_prompt_charing_display();
        return true;
    case view_prompt_finding:
        view_prompt_find_wrist_display();
        return true;
    case view_prompt_not_wear:
        view_prompt_not_wear_display();
        return true;
    case view_prompt_bind_success:
        view_prompt_bind_success_display();
        return true;
    case view_prompt_camera_ready:
        view_prompt_camera_ready_display();
        return true;
    case view_prompt_camera_fail:
        view_prompt_camera_fail_display();
        return true;
#if defined(USE_CT1711)
    case view_prompt_hyperthemia:
        view_prompt_hyperthemia_display();
        return true;
    case view_prompt_body_temperature_fail:
        view_prompt_body_temperature_fail_display();
        return true;
#endif
    }
    return false;
}
bool view_prompt_charing_event(event_param_t param)
{
    if (!battery_ctrl_if_charging())
    {
        return false;
    }
    switch (param.event)
    {
    case BUTTON_EVENT_SHORT_PRESS:
        switch (param.source)
        {
#if defined(R33_BOARD) || defined(SM02_BOARD)
        case event_source_button_side:
        {
            if (disp_ctrl.on == DISP_ON_DISABLE)
            {
                display_show(view_prompt_charing, DISP_MODE_NORMAL);
            }
            else
            {
                disp_ctrl.auto_close_delay = 1;
            }
            break;
        }
#endif
        default:
            if (disp_ctrl.auto_close_delay < DISP_CLOSE_TIME_DEFAULT)
            {
                LOG("close delay restore by key");
                disp_ctrl.auto_close_delay = DISP_CLOSE_TIME_DEFAULT;
            }
            display_show(view_prompt_charing, DISP_MODE_NORMAL);
            return true;
        }
    }
    return false;
}
bool view_prompt_alarm_event(int32_t view, event_param_t param)
{
    switch (param.event)
    {
    case event_view_exit:
        motor_stop();
        return true;
    }
    return false;
}
bool view_prompt_event(int view, event_param_t param)
{
    if (view < view_prompt_start || view >= view_prompt_end)
    {
        return false;
    }
    bool result = false;
    switch (view)
    {
    case view_prompt_message:
        result = view_prompt_message_event(view, param);
        break;
    case view_prompt_alarm:
        result = view_prompt_alarm_event(view, param);
        break;
    case view_prompt_distance_complete:
        result = view_prompt_distance_complete_event(view, param);
        break;
    case view_prompt_calories_complete:
        result = view_prompt_calories_complete_event(view, param);
        break;
    case view_prompt_steps_complete:
        result = view_prompt_steps_complete_event(view, param);
        break;
    case view_prompt_finding:
        result = view_prompt_find_wrist_event(view, param);
        break;
#if defined(USE_CT1711)
    case view_prompt_hyperthemia:
        result = view_prompt_hyperthemia_event(view, param);
        break;
#endif
    }
    if (result)
    {
        return true;
    }
    switch (param.event)
    {
#ifdef EVENT_BUTTON_FRONT
    case event_button_front_long_press:
#endif
#ifdef EVENT_LEVEL_UP
    case event_move_level_up:
#endif
        display_show_type_recover();
        return true;
    }
    return false;
}
